package com.zhkj.txg.utils

import android.app.Activity
import android.content.Context
import com.zhkj.txg.base.CustomApplication
import com.zhkj.txg.module.home.ui.*
import com.zhkj.txg.module.product.ui.ProductDetailActivity
import com.zhkj.txg.module.product.ui.ProductDetailActivity2

/**
 * 根据Type判断跳转位置 0不跳转,1跳转普通商品,2拼团商品,3商品二级分类,4商品三级分类,5会员中心,6店铺
 * (p.s:判断context是否是Activity，非Activity需加flag)
 */
fun typeJump(context: Context, type: Int, params: String?, title: String?) {
//    Log.d("action click", "点击了Banner type:$type, params:$params, title:$title")
    when (type) {
        1 -> if (params != null) {
            ProductDetailActivity2.normalProduct(context, params.toInt(), shopId = CustomApplication.getShopId())
//            ProductDetailActivity.normalProduct(context, params.toInt())
        }
        2 -> if (params != null) {
//            GroupDetailActivity.normalProduct(context, params)
        }
        3 -> if (params != null && context is Activity) {
            CategoryActivity.open(context, params.toInt())
        }
        4 -> if (params != null && context is Activity) {
            ProductListActivity.categoryOpen(
                context, title ?: "", params.toInt(),
                CustomApplication.getShopId()
            )
        }
        6 -> if (params != null) {
//            ShopActivity.open(context, "", params.toInt())
        }
        7 -> if (params != null && context is Activity) {
            EventCommodityActivity.open(context, title ?: "", params.toInt())
        }//活动页面
    }
}